
TRIGGER PROCEDURE FOR DELETE OF PC_MSTR.

{mfdeclre.i }
define new shared work-table wf_old_pc_mstr like pc_mstr.

HK:
do:
    if can-find(first dt_mstr where dt_table = "pc_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "DEL", input recid(pc_mstr), input "pc_mstr").

    if not can-find ( first dt_mstr where dt_table = "pc_mstr" and dt_type = "DEL" ) then leave HK.
    
    if not can-find ( first wf_old_pc_mstr ) then do:
        create wf_old_pc_mstr.
        if recid(wf_old_pc_mstr)= -1 then .
    end.
    
    buffer-copy pc_mstr to wf_old_pc_mstr no-error.

    for first dt_mstr no-lock where dt_table = "pc_mstr" and dt_type = "DEL" :
    
    	run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
        	input recid(pc_mstr), input pc_mstr.pc_list, input pc_mstr.pc_part, input pc_mstr.pc_curr, input pc_mstr.pc_prod_line,
        	input pc_mstr.pc_um, input string(pc_mstr.pc_start), input "", input "") .
        
    end.
end.

{hkdttrans.i}
